# Maintainer: Alexey Pavlov <Alexpux@gmail.com>
# Contributor: Karlson2k (Evgeny Grin) <k2k@narod.ru>

_realname=mpfr
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
_pkgver=4.2.2
pkgver=${_pkgver}
# pkgver=${_pkgver}.p1
pkgrel=1
pkgdesc="Multiple-precision floating-point library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://www.mpfr.org"
msys2_repository_url="https://gitlab.inria.fr/mpfr/mpfr"
msys2_references=(
  "cpe: cpe:2.3:a:mpfr:gnu_mpfr"
)
license=('spdx:LGPL-3.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-gmp")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
source=(https://ftp.gnu.org/gnu/mpfr/${_realname}-${_pkgver}.tar.xz{,.sig})
        # patches.diff) # wget https://www.mpfr.org/mpfr-4.2.0/allpatches -O patches.diff
sha256sums=('b67ba0383ef7e8a8563734e2e889ef5ec3c3b898a01d00fa0a6869ad81c6ce01'
            'SKIP')
validpgpkeys=('A534BE3F83E241D918280AEB5831D11A0D4DB02A')

prepare() {
  cd "${srcdir}/${_realname}-${_pkgver}"

  #patch -p1 -i "${srcdir}"/patches.diff
  autoreconf -fiv
}

build() {
  mkdir -p build-${MSYSTEM} && cd build-${MSYSTEM}

  ../${_realname}-${_pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --enable-static \
    --enable-shared \
    --with-gmp=${MINGW_PREFIX}

  make
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"
  make check
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install
}
